package vn.edu.saigontech.ncms.test.excel;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;

public class ExcelReader {
	
	public ExcelReader() {
	}
	
	public void test() throws IOException {
		InputStream fis = new FileInputStream("C:/sample.xls");;
		POIFSFileSystem fs = new POIFSFileSystem( fis );
		HSSFWorkbook wb = new HSSFWorkbook(fs);
		HSSFSheet sheet = wb.getSheetAt(0);
		HSSFRow row = sheet.getRow(0);
		HSSFCell cell = row.getCell(0);
		
		HSSFRichTextString rts = cell.getRichStringCellValue();
		System.out.println(rts);
		System.out.println(rts.length());
		System.out.println(rts.getFontAtIndex(0));
		System.out.println(rts.getFontAtIndex(1));
		System.out.println(rts.getFontAtIndex(2));
		System.out.println(rts.getFontAtIndex(3));
		System.out.println(rts.getFontAtIndex(4));
		System.out.println(rts.getFontAtIndex(5));
		System.out.println(rts.getFontAtIndex(6));
		System.out.println(rts.getFontAtIndex(7));
		System.out.println(rts.getFontAtIndex(8));
	}
	
	public static void main(String[] args) throws IOException {
		ExcelReader e = new ExcelReader();
		e.test();
	}
}